Introduction
Previous  Top  Next



The Clipbook tool is programmable and supports features such as variables, functions, commands, conditional statements, etc. It also integrates support for Perl and Gawk interpreters; scripts can be stored in Clips and applied directly to highlighted text or a whole document. A good way to learn how the Clip language is used is to look at some of the sample Clipbook libraries provided with NoteTab.

The Clip language has been designed so that it can be mixed with plain text and even other script languages. Because of this, it looks and behaves differently from other programming languages. Clip instructions use tags to clearly delimit them from other text. The language is very easy to learn once you become familiarized with the various syntax elements and their format. Names of the various syntax elements are not case sensitive.

The Clip language understands and uses string (a sequence of characters), integer (negative and positive whole numbers), and Boolean (True/False) data types. However, values are always stored in text format no matter what data type they represent. Conversion between the data types is handled automatically internally. This approach makes the language particularly easy to use even for those with no prior experience in programming.

The "SampleCode.clb" library that is included with NoteTab provides examples for many of the commands and functions explained here. The best way to learn how to use the new Clip language is to look at some of the sample Clips in detail. You can also learn about Clip programming by joining one of the NoteTab mailing lists or by subscribing to the "NoteTab Tips and Tricks" weekly newsletter (information about all this is available at the NoteTab Web site).

Useful tip when testing Clip code:
You can use the "Ctrl+Alt" key combination to stop the execution of a Clip (especially useful when stuck in a loop).


See below for a brief explanation of the various syntax elements.

Clip Language Elements:

Commands:
A command is an instruction that performs a specific task. All commands must start at the beginning of a line with the two-character code "^!" followed either by the name of the Clip command or a program command line. Note that since version 4.8, you can now also have commands after conditional statements. Each command must occupy a single line in the Clip. Many commands accept or require one or more parameters - data that you pass to the instruction that can determine how the command operates. Parameters must be separated with a blank character; if a parameter contains a blank character it must be placed between double-quotes. Example of a command:
^!Close "File Name" SAVE


Functions:
Unlike commands, functions return a result. A function can be placed anywhere in a Clip text but it must not be split by a line break. Functions can also be embedded within each other. Each function is bound by a dollar character "$" and preceded with the circumflex accent "^". Many functions require one or more parameters which must be placed between parenthesis immediately after the function name. If there are several parameters, they must be separated from each other with a semicolon ";". Note that if a parameter contains a semicolon character it must be placed between double-quotes . Example of a function: ^$StrIndex(String;Index)$


Variables:
A variable is a named memory element used for storing values of any data type. It can contain anything from nothing to multiple megabytes of text. A variable can be placed anywhere in a Clip text but it must not be split by a line break. Each variable is bound by a percentage character "%" and preceded with the circumflex accent "^" when referring to the value it contains. A variable is defined as soon as it is used and it is always empty at first - unless you immediately assign a value to it. A variable name can have any character except those that delimit words (space, tab, punctuation, etc.). Example of a variable: ^%MyVariable%


Labels:
Labels are used to mark a place within a Clip to which an instruction can jump. They are useful for controlling the sequence of execution and for creating repeating instructions (loops). A label is defined by starting a line with a colon ":" followed by a name. The name can have any character except those that delimit words (space, tab, punctuation, etc.). You can jump to a label with the ^!Goto command or after a conditional operation. Labels are skipped over when not used within a set of instructions. The scope of a label is limited to the Clip in which it is defined. A Clip should not contain duplicate label definitions (only the first occurrence would be used). Example of a label:
:MyLabel


Events:
Events are triggered when something particular happens in the program or Windows. The Clip language recognizes four distinct events: the opening and closing of a Clipbook library, sending text to the Clipboard, and timer intervals. You can execute Clip code when these events are triggered. Timer events are controlled with the "^!TimerPlay" command; the three other events are defined by creating Clips with the corresponding event name (OnOpen, OnClose, OnClipboardChange).

Comments:
Inserting comments in a Clip is very easy: just place a semicolon (;) at the start of each line containing a comment. If you come across a situation when a line in a Clip should start with a semicolon and it is not a comment, just add an extra semicolon in front of it. Note that comments are only valid within a Clip!

Errors:
When the Clip interpreter encounters a syntax error, it displays an error message and the line in which the fault was encountered. The line number indication, however, does not take into account eventual comments that may have been inserted between the instructions. The reason behind this is that comments are stripped from the code before it is executed.


Parsing and evaluation sequence

A. Whole Clip

1. Comments removed
2. Date fields evaluated ^[...^]
(old format)
3. Text selection inserted if ^&
found
4. ^!CONTINUE
command executed if on first line
5. Clip wizard based on ^?[...]
fields displayed
6. Mathematical fields evaluated ^$[...]
(old format)

B. Line by line

1. Variables resolved (from right to left)
2. Document name using ^*
, ^**, ^#, ^## codes resolved
3. Functions resolved (from right to left)
4. Clip wizard based on ^?{...}
fields in line displayed
5. Clip Command executed


Clip Language Topics

Labels
Variables
Events
Custom Functions
Testing Conditions
Message Boxes / Prompts
Text Processing
HTML Processing
Select, Copy, and Insert Text
Clipboard Copy / Paste
Find / Replace Text
Document Processing
Document Management
Disk Files
Disk Directories
Executing Programs
Using Perl, Gawk, and Other Scripts
Using Other Clips
Clipbars
Toolbar Commands
Keyboard Macros
Windows Registry and Shortcuts
Miscellaneous Commands / Functions
Mathematics
Dates
Clip Wizard and Fields
Masked Input Fields